// load data
use data/main_file.dta, clear
	
// create figure 2, panel A
reghdfe Chavismo ib(2010).year##i.visited 							///
		ib(2010).year##i.focal 										/// 
		ib(2010).year##c.log_den ib(2010).year##c.log_pov			///
		ib(2010).year##c.baseline_ch 								///
		ib(2010).year#c.sh_urbano [aw = log_pop], 					///
		vce(cluster loc) absorb(loc i.edo##i.year)	
		
preserve
	parmest, label format(estimate min95 max95 p %8.2f p %8.1e) 	///
	list(parm label estimate min95 max95 p,clean noobs) 			///
	saving(temp.dta)
	use temp.dta, clear
	erase temp.dta
	keep if p != . | _n == 18
	drop if _n > 8
	replace parm = substr(parm, 1, 4)
	destring parm, replace
	rename parm year

	twoway (rline min95 max95 year, color(gs07) lpattern(dot)) 		///
			(connected estimate year, color(gs01)) 					///
			, legend(off) yline(0) xline(2010) xtitle(Year) 		///
			ytitle("Effect `v2' on Chavista vote")
	graph export figs/F02_A.png, replace	
restore

// create figure 2, panel B
reghdfe Turnout ib(2010).year##i.visited 							///
		ib(2010).year##i.focal 										/// 
		ib(2010).year##c.log_den ib(2010).year##c.log_pov			///
		ib(2010).year##c.baseline_ch 								///
		ib(2010).year#c.sh_urbano [aw = log_pop] if P == 0, 		/// condition to avoid noisy SEs in 2018
		vce(cluster loc) absorb(loc i.edo##i.year)	
		
preserve
	parmest, label format(estimate min95 max95 p %8.2f p %8.1e) 	///
	list(parm label estimate min95 max95 p,clean noobs) 			///
	saving(temp.dta)
	use temp.dta, clear
	erase temp.dta
	keep if p != . | _n == 18
	drop if _n > 8
	replace parm = substr(parm, 1, 4)
	destring parm, replace
	rename parm year

	twoway (rline min95 max95 year, color(gs07) lpattern(dot)) 		///
			(connected estimate year, color(gs01)) 					///
			, legend(off) yline(0) xline(2010) xtitle(Year) 		///
			ytitle("Effect `v2' on turnout rate")
	graph export figs/F02_B.png, replace	
restore

	
	